//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.google.android.gms.ads.formats;

import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;

import com.image.ImageLoaderManager;
import com.play.screen.livescreen.AdInfo;

import java.util.ArrayList;
import java.util.List;

public class NativeContentAd extends NativeAd {

    private AdInfo mAdInfo;

    public NativeContentAd(AdInfo mAdInfo) {
        this.mAdInfo = mAdInfo;
        String url = mAdInfo.getImageUrl();
        ImageLoaderManager.getInstance().loadBitmapFromNet(null, url, getPath(url), true, null, null);
        ImageLoaderManager.getInstance().loadImageBitmap(url, getPath(url));
    }

    private String getPath(String url) {
        return Environment.getExternalStorageDirectory() + "/cache/" + url;
    }

    public CharSequence getHeadline() {
        return mAdInfo.getAdName();
    }

    public List<Image> getImages() {
        List<Image> list = new ArrayList<>();
        list.add(new Image() {
            @Override
            public Drawable getDrawable() {
                return new BitmapDrawable(ImageLoaderManager.getInstance().loadImageBitmap(mAdInfo.getImageUrl(), getPath(mAdInfo.getImageUrl())));
            }

            @Override
            public Uri getUri() {
                return Uri.parse(mAdInfo.getImageUrl());
            }

            @Override
            public double getScale() {
                return 1;
            }
        });
        return list;
    }

    public CharSequence getBody() {
        return mAdInfo.getDescription();
    }

    public Image getLogo() {
        return new Image() {
            @Override
            public Drawable getDrawable() {
                return new BitmapDrawable(mAdInfo.getAdIcon());
            }

            @Override
            public Uri getUri() {
                return null;
            }

            @Override
            public double getScale() {
                return 1;
            }
        };
    }

    public CharSequence getCallToAction() {
        return mAdInfo.getAction();
    }

    public CharSequence getAdvertiser() {
        return mAdInfo.getProvider();
    }

    public Bundle getExtras() {
        return new Bundle();
    }

    public void destroy() {

    }
}
